<template>


	<div>

		<p>模板名称</p>

		<input type="text" v-model="templateName" />

		<p>模板内容</p>

		<input type="text" v-model="templateValue">

		<el-button @click="submit">提交模板</el-button>
		<el-button @clikc="reset">重置</el-button>


	</div>

</template>

<script>
	export default {

		data() {

			return {
				templateName: "",
				templateValue: ""
			}

		},
		methods: {

			// 提交
			submit() {

				let templateType = 'miaosai' // 短信平台
				let templateName = this.templateName // 短信模板名称
				let templateValue = this.templateValue // 短信模板内容
				let api = this.$api.ems
				this.$axios({
					url: api,
					method: "POST",
					params: {
						"action": "add",
						"params": {
							templateType,
							templateName,
							templateValue
						}
					}
				}).then(res => {
					// console.log(res.data);
					if (res.data.code == 2024) {
						this.$message({
							message: '添加模板成功',
							type: 'success'
						});
						this.$store.commit('addEmsTemplate', [res.data.data])
						
						this.templateName = ""
						this.templateValue = ""
					}else{
						this.$message({
							message:res.data.msg,
							type: 'error'
						});
					}
				}).catch(err=>{
					console.log(err);
				})
			},
			// 重置
			reset() {




			}


		}

	}
</script>

<style>
</style>
